Skip to main content

Export And Commit Table Schemas

πŸ“„ <ENV> - [BigQuery] Export and Commit Table Schemas​

This GitHub Actions workflow automates the extraction of BigQuery table schemas from the bqDataLake dataset and commits them to the repository. It helps ensure that your schema definitions remain version-controlled and in sync with BigQuery.


πŸ“Œ Workflow Trigger​

This workflow is triggered manually via the GitHub actions in function repo.


πŸ’  Environment Variables​

VariableDescription
GCP_PROJECT_IDGCP Project ID (e.g., biddirect-2)
DATASET_IDBigQuery dataset ID (e.g., bqDataLake)

🧱️ Workflow Job: export-and-commit-bigquery-schemas​

StepDescription
Checkout repositoryClones the GitHub repository to the runner.
Authenticate with GCPAuthenticates using a service account (<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets.
Set up Cloud SDKInstalls and configures the Google Cloud SDK CLI.
Create output directoryCreates the directory to store schema JSON files.
Get all schemas from BigQueryIterates over all tables in the dataset (excluding _changelog and non-table types), exports schema definitions, and saves them to local files.
Commit and Push Schema FilesStages and commits any updated schema files to the repository.

🧹 Export Logic Summary​

  • Skips tables ending with _changelog

  • Skips views or other non-TABLE resources

  • Removes _latest suffix from table names when naming schema files

  • Stores output in:

    functions/src/bqDataLake/definitions/tableSchemas/

Example:

Table: accounts_latest β†’ File: accounts.json

πŸ” Required Secrets​

Secret NameDescription
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNTService account key JSON for GCP auth.

βœ… Example Usage​

To run this workflow:

  1. Go to the Actions tab in your GitHub repository.
  2. Select the workflow <ENV> - [BigQuery] Export and Commit Table Schemas.
  3. Click "Run workflow".

This will:

  • Export schemas for all physical _latest tables in the bqDataLake dataset
  • Save each schema in JSON format to the repo
  • Automatically commit and push the updated files to the branch from which the workflow was executed

This workflow ensures that schema changes are tracked alongside application code.